package huaabdelmartin_stage2;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JFrame;
import javax.swing.JTextArea;

public class DeskGUI extends JFrame implements Observer{
	
	//instance variables
	TheBrain brain;
	
	private ArrayList<JTextArea> desks = new ArrayList<JTextArea>();
	
	public DeskGUI(TheBrain brain){
		this.brain = brain;
	    brain.addObserver(this);

	}

	@Override
	public void update(Observable o, Object arg1) {
		// TODO Auto-generated method stub
		/*for( Worker w : brain.getWorkerList() ){//go through each worker and get currentTaxi/currentPG
			int workerIndex = brain.getWorkerList().indexOf(w);
			desks.get(workerIndex).setText( w.getCurrentTaxi().toString() + w.getCurrentPG().toString() );
		}*/
		this.showData();
	}

	public void showData(){
		for(Worker w: brain.getWorkerList()){
			if(w.hasData()){
				System.out.println("worker"+w.hashCode()+" has:"+w.getCurrentTaxi().toString()+" and " + w.getCurrentPG().toString());
			}
			else{}
		}

	}
}
